package com.bw.controller;

import com.bw.been.Sugar;
import com.bw.been.SugarThree;
import com.bw.been.SugarTwo;
import com.bw.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class OrderController {

    @Autowired
    OrderService orderService;

    @RequestMapping("getList1")
    public List getList1(){
        List<Sugar> list = orderService.getList1();
        return list;
    }

    @RequestMapping("getList2")
    public List getList2(){
        List<Sugar> list = orderService.getList2();
        return list;
    }

    @RequestMapping("getList3")
    public List getList3(){
        List<SugarTwo> list = orderService.getList3();
        return list;
    }

    @RequestMapping("getList4")
    public List getList4(){
        List<SugarThree> list = orderService.getList4();
        return list;
    }

    @RequestMapping("del")
    public String del(){
        Integer id = 5;
        int i  = orderService.del(id);
        System.out.println(i>0?"删除成功":"删除失败");
        return "删除成功";
    }

    @RequestMapping("add")
    public String add(){
        SugarThree sugar = new SugarThree(5,"湖南");
        int i  = orderService.add(sugar);
        System.out.println(i>0?"添加成功":"添加失败");
        return "添加成功";
    }
}
